<?php
session_start();

include_once 'recursos/config.php';
include_once 'recursos/fechas.php';

$conf = new configuracion();
$fecha = new fechas();

$dominio = $conf->getG2uDominio()."/";

$cant_comment = "No hay comentarios";
$who_comment = "";
$temp = "";

if (is_array($_SESSION["g2uActualPhotoComment"]) && !empty($_SESSION["g2uActualPhotoComment"])) {
    $cant_comment = count($_SESSION["g2uActualPhotoComment"]);
    $cant_comment .= " <img src=\'".$dominio."images/png/comentario.png\' />";
    
    $cant_comment2 = "<img src=\'".$dominio."images/png/comentario.png\' />";
    $cant_comment2 .= count($_SESSION["g2uActualPhotoComment"]);
    
    
    foreach ($_SESSION["g2uActualPhotoComment"] as $key => $value) {
        $temp[$value['uname']] = $value['uname'];
    }

    foreach ($temp as $key => $v) {
        $who_comment .= $v."<br/>";
    }
}

?>
<script>
    $(document).ready(function(){
        $("#c_cont").html('<span title="<?=$who_comment?>" alt="<?=$who_comment?>"> <?=$cant_comment?> </span>');
        $("#c_cont_<?=$_REQUEST["pid"]?>").html('<span title="<?=$who_comment?>" alt="<?=$who_comment?>"> <?=$cant_comment2?> </span>');
        $('span').tipsy({html: true });
        
        $("#comments_list").mCustomScrollbar({
            theme:"dark"
        });
    });

</script>
<?

if (is_array($_SESSION["g2uActualPhotoComment"]) && !empty($_SESSION["g2uActualPhotoComment"])) {
    $ctaLimit = 1;
    foreach ($_SESSION["g2uActualPhotoComment"] as $key => $value) {
?>
        <table width='100%' cellpadding = '3px' cellspacing="0">
            <tr>
                <td width='36px'>
                    <img src='<?=$dominio.$value["upic"]?>' width='36px' />
                </td>
                <td>
                    <b><?=$value['uname']?></b>  <br/>
                       <?=htmlspecialchars($value['desc'])?>         <br/>
                    <i><?=$fecha->convertirFechatoNormal($value['fecha'])." ". $fecha->getHoraFromMyslToNormal($value['fecha']) ?> </i>
                </td>
            </tr>
        </table>
<?php
        if(isset($_REQUEST["limit"]) && $_REQUEST["limit"]>0){
            if ($_REQUEST["limit"] == $ctaLimit){
                break;
            }else{
                $ctaLimit++;
            }
        }
    }
} else {
    ?>
    S&eacute; el primero en comentar!
    <?php
}
?>